<?php

namespace App\Services\Admin;

use App\Models\ClassBase as ClassBaseModel;
use App\Models\ClassBaseNumbering as ClassBaseNumberingModel;

class ClassBase extends Base
{
    public static function lists()
    {

        $input = request()->all();

        $where = [];

        if (!empty($input['store_id'])) $where[] = ['store_id', $input['store_id']];
        if (!empty($input['class_base_numbering'])) $where[] = ['class_base_numbering_id', $input['class_base_numbering']];
        if (!empty($input['sear_value'])) $where[] = ['class_name', 'like', '%' . $input['sear_value'] . '%'];

        return (new ClassBaseModel)->with(['store','numbering'])->where($where)->orderBy('id','desc')->paginate(6);

    }

    public static function info($id)
    {
        return (new ClassBaseModel)->where('id', $id)->first();
    }

    public static function add($param = [])
    {
        return (new ClassBaseModel)->insert($param);
    }

    public static function edit($id , $param=[])
    {
        return (new ClassBaseModel)->where('id',$id)->update($param);
    }
}
